package twentytwenty;

/**
 * @Author: Spider Man
 * @Description: 58.最后一个单词的长度
 * @Date Created in 2020-09-22 16:27
 * @Modified By:
 */
public class LengthOfLastWord_58 {
    public static void main(String[] args) {
        String s = " ";
        System.out.println(lengthOfLastWord(s));
    }

    public static int lengthOfLastWord(String s) {
        if (s.length() == 0){
            return 0;
        }
        String[] s1 = s.split(" ");
        if (s1.length == 0) return 0;
        int len = s1.length;
        return s1[len - 1].length();
    }
}
